package com.stock.config;

import com.stock.filter.PointInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    // 注册拦截器
    @Bean
    public PointInterceptor pointInterceptor() {
        return new PointInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器，设置拦截的路径
        registry.addInterceptor(pointInterceptor())
                .addPathPatterns("/**")  // 拦截所有路径
                .excludePathPatterns("/user/**");  // 排除登录和注册等不需要积分的路径
    }

}
